"use strict";

module.exports = function (sequelize, DataTypes) {
    var Stock = sequelize.define("Stock", {
        code: {
            type: DataTypes.STRING,
            primaryKey: true
        },
        name: {
            type: DataTypes.TEXT,
        },
        avgRating: {
            type: DataTypes.TEXT
        },
        action: {
            type: DataTypes.TEXT
        }
    },
        {
            freezeTableName: true,
            paranoid: true
        });

    Stock.associate = function (models) {
        var Ratings = models.Ratings;
        Stock.hasMany(Ratings);
        Ratings.belongsTo(Stock);

        var RatingHistory = models.RatingHistory;
        Stock.hasMany(RatingHistory);
        RatingHistory.belongsTo(Stock);
    }

    return Stock;
};